// 引入axios实例
import request from '@/utils/request'
export default{
  // 1、新增\保存课程信息：向后端发送请求，保存课程信息到数据库，需要在请求体中传参，参数是一个对象[可以结合后端代码进行编写]
  saveCourseInfo(courseInfo) {
    return request({
      url: '/admin/edu/course/save-course-info',
      method: 'post',
      data: courseInfo
    })
  },
  // 2、新增\保存章节信息
  saveChapter(chapter) {
    return request({
      url: '/admin/edu/chapter/save-chapter',
      method: 'post',
      data: chapter
    })
  },
  // 3、查询单个课程对应的所有章节及课时的嵌套集合
  chapterNestedList(courseId) {
    return request({
      url: `/admin/edu/chapter/list/${courseId}`,
      method: 'get'
    })
  },
  // 4、删除章节
  deleteChapater(chapterId) {
    return request({
      url: `/admin/edu/chapter/removeChapterById/${chapterId}`,
      method: 'delete'
    })
  },
  // 5、根据id查询章节对象
  getChapter(chapterId) {
    return request({
      url: `/admin/edu/chapter/getChapterById/${chapterId}`,
      method: 'get'
    })
  },
  // 6、更新章节
  updateChapter(chapter) {
    return request({
      url: `/admin/edu/chapter/updateById`,
      method: 'put',
      data: chapter
    })
  },
  // 7、根据课程id，查询发布课程信息
  getCoursePublishById(courseId) {
    return request({
      url: `admin/edu/course/course-publish/${courseId}`,
      method: 'get'
    })
  },
  // 8、根据课程id，更新发布课程信息
  publishCourseById(courseId) {
    return request({
      url: `admin/edu/course/publish-course/${courseId}`,
      method: 'put'
    })
  },
  // 9、根据课程id，查询课程基本信息，进行回显
  getCourseInfoById(courseId) {
    return request({
      url: `/admin/edu/course/course-info/${courseId}`,
      method: 'get'
    })
  },
  // 10、根据课程id，更新课程基本信息
  updateCourseInfoById(courseId, course) {
    return request({
      url: `/admin/edu/course/update-course-info/${courseId}`,
      method: 'put',
      data: course
    })
  }
}
